$(function () {
    //今日是否有直播
    getToDayLive();
    // 未读消息数
    getUnreadMessage();
    //用户是否是会员
    getisUserMember();



    function getToDayLive() {
        $.ajax({
            url: baseloaction + '/web/uc/course/play/record/getToDayLive',
            type: 'post',
            success: function (response) {
                if (response.success) {
                    var count = response.entity;
                    if (count > 0) {
                        $(".not-live").show();
                    } else {
                        $(".not-live").hide();
                    }
                }
            }
        });
    }

    function getUnreadMessage() {
        //设置消息下次获取时间
        var messageState = getCookie("messageState");
        if (messageState == null || messageState == "" || messageState == undefined) {
            $.ajax({
                url: baseloaction + '/web/uc/affiche/countReceiveAffiche',
                type: 'post',
                success: function (response) {
                    if (response.success) {
                        var count = response.entity;
                        if (count && count != 0) {
                            // 获取当前日期对应的时间戳并生成过期时间戳3分钟后过期
                            SetCookieOutTime("messageState", true, "s180");
                            SetCookieOutTime("messageCount", count, "s180");
                            $('#head-afficheNum-pointer').text(count).removeClass('hide');
                        } else {
                            $('#head-afficheNum-pointer').addClass('hide');
                        }
                    }
                }
            });
        } else {
            var messageCount = getCookie("messageCount");
            if (messageCount != "" && messageCount != null && messageCount != 0) {
                $('#head-afficheNum-pointer').text(messageCount).removeClass('hide');
            } else {
                $('#head-afficheNum-pointer').addClass('hide');
            }

        }
    }


    //获取用户是否为会员
    function getisUserMember() {
        //设置消息下次获取时间
        var isUserMemberCookie = getCookie("isUserMember");
        if (isUserMemberCookie == null || isUserMemberCookie == "" || isUserMemberCookie == undefined) {
            $.ajax({
                url: baseloaction + '/web/uc/isUserMember',
                type: 'post',
                success: function (response) {
                    var isUserMember = response.entity;
                    if (response.success) {
                        SetCookieOutTime("isUserMember", isUserMember, "s10");
                        if (isUserMember) {
                            $("#isUserMember").removeClass("hide");
                        } else {
                            $("#isUserMember").addClass("hide");
                        }
                    }
                }
            });
        } else {
            if (getCookie("isUserMember") == "true") {
                $("#isUserMember").removeClass("hide");
            } else {
                $("#isUserMember").addClass("hide");
            }
        }
    }
});